package com.fhz.common.manage

import android.app.Activity
import java.util.Stack

/**
 * 时间:2023/4/6
 * @author Mr.Feng
 * 简述: Activity的管理类.复制加入,或者删除一个Activity
 */
object MyActivityManage {

    private  val  stack =  Stack<Activity>()

    //添一个
    fun addActivity(activity: Activity){
        stack.add(activity)
    }


    fun removeActivity(activity: Activity){
        stack.remove(activity)
    }

    //从栈中异常,并没有删除
    fun removeAllActivity(){
        for (a in stack){
            stack.remove(a)
        }
    }

    //获取当前的界面
    fun getCurrentActivity() : Activity{
        return stack.lastElement()
    }

    //结束一个
    fun finish(activity: Activity){
        activity.finish()
    }

    //结束所有
    fun finishAll(){
        for (a in stack){
            a.finish()
        }
        stack.clear()
    }





}